# 检测回文数
# 10000 - num_input
from pprint import pprint

# num_input = int(input())
num_input = 10009
# 10001

def check_is_huiwen(i):
    # i 是不是 回文 是回文才能返回是
    ss= str(i)
    if(ss==ss[::-1]):
        return True
    return False

arr_result=[]
for i in range(10000,num_input+1):
    # print(i)
    is_hui=check_is_huiwen(i)
    if(is_hui):
        arr_result.append(i)
# for e in arr_result:
#     print(e)
print(len(arr_result))
